<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <script src="./01.directive.js"></script>
    <style>
        .img{
            width:300px;
            height:300px;
            border:1px solid black;
            background-color:rgba(0,0,0,0.1);
        }
        .div{
            width:300px;
            height: 300px;
            border:1px solid black;
            background-color:rgba(0,0,0,0.1);
        }
    </style>
</head>
<body>
    <div id="app">
        <img class="img" v-preload:fill="img1">
        <img class="img" v-preload:cover="img2">
        <img class="img" v-preload:scale-down="img3">
        <hr>
        <div class="div" v-preload.bg="img1"></div>
    </div>
</body>
<script>
    // Vue.directive("preload",function(el,binding){
    //     el.src="../img/5-121204193935-51.gif";
    //     el.style.objectFit="none";
    //     el.style.objectPosition="center";
    //     let img=new Image();
    //     img.src=binding.value;
    //     img.onload=function(){
    //         el.src=binding.value;
    //         el.style.objectFit=binding.arg;
    //     }
    // })
    var vm=new Vue({
        el:"#app",
        data:{
            img1:"http://img4.imgtn.bdimg.com/it/u=1878125254,116198046&fm=11&gp=0.jpg",
            img2:"http://img1.imgtn.bdimg.com/it/u=3989920116,1079056685&fm=11&gp=0.jpg",
            img3:"http://img1.imgtn.bdimg.com/it/u=3864356172,2798213327&fm=26&gp=0.jpg"
        }
    })
</script>
</html>